package org.custom.spring.boot.datasource.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * 支持的数据源类型
 *
 * @author 李坤
 * @date 2022/3/31 15:47
 */
public class SupportDataSourceType {
    public static List<DataSourceType> dataSourceTypes;

    static {
        dataSourceTypes = new ArrayList<>();

        // 支持DB2
        dataSourceTypes.add(new DataSourceType("jdbc:db2://127.0.0.1:50000/jett", "DB2", "com.ibm.db2.jcc.DB2Driver"));
        // 支持Oracle
        dataSourceTypes.add(new DataSourceType("jdbc:oracle:thin:@127.0.0.1:1521:ORCL", "Oracle", "oracle.jdbc.OracleDriver"));
        // 支持 MySQL5.5
        dataSourceTypes.add(new DataSourceType("jdbc:mysql://127.0.0.1:3306/jett?characterEncoding=UTF-8&useUnicode=true&useSSL=false&serverTimezone=GMT%2B8&tinyInt1isBit=false", "MySQL5.5", "com.mysql.jdbc.Driver"));
        // 支持 MySQL5.7+
        dataSourceTypes.add(new DataSourceType("jdbc:mysql://127.0.0.1:3306/jett?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&tinyInt1isBit=false", "MySQL5.7+", "com.mysql.cj.jdbc.Driver"));
    }

    public static List<DataSourceType> getDataSourceTypes() {
        return SupportDataSourceType.dataSourceTypes;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class DataSourceType {
        /**
         * 默认数据源名称
         */
        private String url;

        /**
         * 数据源名称
         */
        private String name;

        /**
         * 数据源驱动名称
         */
        private String driverClassName;
    }
}
